using System;
using System.ComponentModel;
using System.Text;

namespace UnitTests
{
  public class PropertyChangedHandler : IDisposable
  {
    private readonly INotifyPropertyChanged _obj;
    private readonly StringBuilder _sb = new StringBuilder();

    public PropertyChangedHandler(INotifyPropertyChanged obj)
    {
      _obj = obj;
      _obj.PropertyChanged += OnPropertyChanged;
    }

    private void OnPropertyChanged(object sender, PropertyChangedEventArgs args)
    {
      if (_sb.Length > 0) _sb.Append(", ");
      _sb.Append(args.PropertyName);
    }

    public void Dispose()
    {
      _obj.PropertyChanged -= OnPropertyChanged;
    }

    public string Log
    {
      get { return _sb.ToString(); }
    }
    public override string ToString()
    {
      return Log;
    }
  }
 /* public class EventTracer : IDisposable
  {
    private readonly object _obj;
    private readonly string _eventName;
    private readonly StringBuilder _sb = new StringBuilder();

    public EventTracer(object obj, string[] eventName)
    {
      _obj = obj;
      _eventName = eventName;
      _obj.PropertyChanged += OnPropertyChanged;
    }

    private void OnPropertyChanged(object sender, PropertyChangedEventArgs args)
    {
      if (_sb.Length > 0) _sb.Append(", ");
      _sb.Append(args.PropertyName);
    }

    public void Dispose()
    {
      _obj.PropertyChanged -= OnPropertyChanged;
    }

    public string Log
    {
      get { return _sb.ToString(); }
    }
    public override string ToString()
    {
      return Log;
    }
  }*/
}